"""更新迁移文件

Revision ID: 1a9cd4a1181c
Revises: 86b864bad82f
Create Date: 2022-04-11 09:57:47.023346

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1a9cd4a1181c'
down_revision = '86b864bad82f'
branch_labels = None
depends_on = None


def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()





def upgrade_main():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('vadmin_auth_user',
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('joined_time', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True, comment='创建时间'),
    sa.Column('update_time', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True, comment='更新时间'),
    sa.Column('avatar', sa.String(length=500), nullable=True, comment='头像'),
    sa.Column('telephone', sa.String(length=11), nullable=False, comment='手机号'),
    sa.Column('name', sa.String(length=50), nullable=False, comment='姓名'),
    sa.Column('nickname', sa.String(length=50), nullable=True, comment='昵称'),
    sa.Column('password', sa.String(length=255), nullable=True, comment='密码'),
    sa.Column('gender', sa.String(length=8), nullable=False, comment='性别, 0男1女'),
    sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否可用'),
    sa.Column('is_staff', sa.Boolean(), nullable=True, comment='管理员'),
    sa.Column('is_cancel', sa.Boolean(), nullable=True, comment='是否注销'),
    sa.Column('from_platform', sa.String(length=50), nullable=True, comment='来自平台/创建于哪个平台系统'),
    sa.Column('last_ip', sa.String(length=50), nullable=True, comment='最后一次登录IP'),
    sa.Column('last_login', sa.DateTime(), nullable=True, comment='最近一次登录时间'),
    sa.Column('wechat', sa.String(length=50), nullable=True, comment='微信'),
    sa.Column('qq', sa.String(length=50), nullable=True, comment='QQ'),
    sa.PrimaryKeyConstraint('id'),
    comment='主管理系统用户表'
    )
    with op.batch_alter_table('vadmin_auth_user', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_vadmin_auth_user_id'), ['id'], unique=True)
        batch_op.create_index(batch_op.f('ix_vadmin_auth_user_name'), ['name'], unique=False)
        batch_op.create_index(batch_op.f('ix_vadmin_auth_user_telephone'), ['telephone'], unique=True)

    # ### end Alembic commands ###


def downgrade_main():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('vadmin_auth_user', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_vadmin_auth_user_telephone'))
        batch_op.drop_index(batch_op.f('ix_vadmin_auth_user_name'))
        batch_op.drop_index(batch_op.f('ix_vadmin_auth_user_id'))

    op.drop_table('vadmin_auth_user')
    # ### end Alembic commands ###


def upgrade_saas_service_temp():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('sadmin_auth_user',
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('joined_time', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True, comment='创建时间'),
    sa.Column('update_time', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True, comment='更新时间'),
    sa.Column('telephone', sa.String(length=50), nullable=False, comment='手机号'),
    sa.Column('name', sa.String(length=50), nullable=False, comment='姓名'),
    sa.Column('gender', sa.String(length=8), nullable=False, comment='性别, 0男1女'),
    sa.Column('nickname', sa.String(length=50), nullable=True, comment='昵称'),
    sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否可用'),
    sa.Column('is_cancel', sa.Boolean(), nullable=True, comment='是否注销'),
    sa.Column('wechat', sa.String(length=50), nullable=True, comment='微信'),
    sa.Column('qq', sa.String(length=50), nullable=True, comment='QQ'),
    sa.Column('avatar', sa.String(length=500), nullable=True, comment='头像'),
    sa.PrimaryKeyConstraint('id'),
    comment='服务系统用户表'
    )
    with op.batch_alter_table('sadmin_auth_user', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_sadmin_auth_user_id'), ['id'], unique=True)
        batch_op.create_index(batch_op.f('ix_sadmin_auth_user_name'), ['name'], unique=False)
        batch_op.create_index(batch_op.f('ix_sadmin_auth_user_telephone'), ['telephone'], unique=True)

    # ### end Alembic commands ###


def downgrade_saas_service_temp():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('sadmin_auth_user', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_sadmin_auth_user_telephone'))
        batch_op.drop_index(batch_op.f('ix_sadmin_auth_user_name'))
        batch_op.drop_index(batch_op.f('ix_sadmin_auth_user_id'))

    op.drop_table('sadmin_auth_user')
    # ### end Alembic commands ###


def upgrade_saas_service1():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('sadmin_auth_user',
    sa.Column('id', sa.Integer(), nullable=False, comment='主键ID'),
    sa.Column('joined_time', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True, comment='创建时间'),
    sa.Column('update_time', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True, comment='更新时间'),
    sa.Column('telephone', sa.String(length=50), nullable=False, comment='手机号'),
    sa.Column('name', sa.String(length=50), nullable=False, comment='姓名'),
    sa.Column('gender', sa.String(length=8), nullable=False, comment='性别, 0男1女'),
    sa.Column('nickname', sa.String(length=50), nullable=True, comment='昵称'),
    sa.Column('is_active', sa.Boolean(), nullable=True, comment='是否可用'),
    sa.Column('is_cancel', sa.Boolean(), nullable=True, comment='是否注销'),
    sa.Column('wechat', sa.String(length=50), nullable=True, comment='微信'),
    sa.Column('qq', sa.String(length=50), nullable=True, comment='QQ'),
    sa.Column('avatar', sa.String(length=500), nullable=True, comment='头像'),
    sa.PrimaryKeyConstraint('id'),
    comment='服务系统用户表'
    )
    with op.batch_alter_table('sadmin_auth_user', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_sadmin_auth_user_id'), ['id'], unique=True)
        batch_op.create_index(batch_op.f('ix_sadmin_auth_user_name'), ['name'], unique=False)
        batch_op.create_index(batch_op.f('ix_sadmin_auth_user_telephone'), ['telephone'], unique=True)

    # ### end Alembic commands ###


def downgrade_saas_service1():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('sadmin_auth_user', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_sadmin_auth_user_telephone'))
        batch_op.drop_index(batch_op.f('ix_sadmin_auth_user_name'))
        batch_op.drop_index(batch_op.f('ix_sadmin_auth_user_id'))

    op.drop_table('sadmin_auth_user')
    # ### end Alembic commands ###

